<!--
  File Name: addLeaveForm.php
  Version 1.0
  O1-31-2011
-->

<?php

class addLeaveForm
{
	public function addNewLeave($employeeNumber, $gender){
?>

		<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Leave App Home</title>
<link href="template.css" rel="stylesheet" type="text/css" media="screen" />
<script language='javascript'>
	function undertimeIsSelected()
	{
		var hoursPrompt = \"\", minutesPrompt = \"\";
		if (document.getElementById('typeOfLeave').value == 'UNDERTIME'  || document.getElementById('typeOfLeave').value == 'TARDINESS') {
			do{									
				var x = prompt('Input Hours '+hoursPrompt, 'hours');									
				if(parseInt(x)>12){
					hoursPrompt = \": Maximum hours is 12 hours.\";	
				}
				else {										
					if (parseInt(x)<0) {
						hoursPrompt = \": Invalid hours.\";										
					} else {
						hoursPrompt = \"\";										
					}										
				}
			}while(isNaN(x) || x>12 || x<0);
			if(x != null){
				do{
					var y = prompt('Input Minutes '+minutesPrompt, 'minutes');
					if(parseInt(y)>60){
						minutesPrompt = \": Maximum minutes is 60 minutes.\";										
					}
					else {
						if (parseInt(y)<0) {
							minutesPrompt = \": Invalid minutes.\";										
						} else {
							minutesPrompt = \"\";										
						}
					}
				}while(isNaN(y) || y>60 || y<0);
				if(y != null){
					var days = (parseInt(60*x) + parseInt(y))/1440;
					if(isNaN(days)) document.getElementById('days').value = '';
					else {
						document.getElementById('days').value = days;
						var d = parseInt(x) + '/' + parseInt(y);
						document.getElementById('time').value=d;
						//var column = document.getElementById('row2').insertCell(8);
						//d = '<input type=\'hidden\' id=\'time\' name=\'time\' value=' + d + '>';
						//column.innerHTML=d;
					}
				}
			}
		} else { document.getElementById('time').value=''; }
	}
	
</script>				
<script src="jquery.js"></script>		
		<script>
			function registerpage(){
				window.location = "register.php";
			}		
				
			$(document).ready(function(){
								   
			   $("a").css({
				'text-decoration':'none',
			   });
			   $("a").hover(function () {
					$(this).css({'text-decoration':'none','color':'blue','font-weight':'bold'});
				  }, function () {
					var cssObj = {
					  'text-decoration':'none',
					  'color' : '',
					  'font-weight':''
					}
					$(this).css(cssObj);
				  });
							   			   
			   $("#submit").css({
					'background-color':'white',
					'color':'#2F2825'
				});
				$("#submit").hover(function () {
					$(this).css({'background-color' : '#993333','color':'white','font-weight':'bold'});
				  }, function () {
					var cssObj = {
					  'background-color' : 'white',
					  'color' : '#2F2825',
					  'font-weight':''
					}
					$(this).css(cssObj);
				  });				  
				
				$("td").css({
					'float: left'
				});
			 
			 });
		</script>
</head>
<body>
<!-- start header -->
<div id="header">
	<div id="logo">
		<h1><span>UPLB</span> &nbsp; Leave Application</h1>
		<p></p>
	</div>
</div>
<!-- end header -->
<div id="wrapper">
	<!-- start page -->
	<div id="page">
	<div id="page-bg">
		<div id="sidebar1" class="sidebar">			
		</div>
		<!-- start content -->
		<div id="content">
			<div class="post">				
				<div class="entry">
					<form name='addLeave' id='addLeave' method='post' action='validateAdd.php'>
						<table id='leaveTable'>			
							<tr>						
								<td>Date of Filing <font size='1'>(mm/dd/yyyy)</font></td>
								<td>
									<input type='text' name='dateOfFiling'id='dateOfFiling'maxlength='10'/>
								</td>
							</tr>
							<tr>
								<td>Date Received <font size='1'>(mm/dd/yyyy)</font></td>
								<td>
									<input type='text' name='dateReceived' id='dateReceived'maxlength='10'/>
								</td>
							</tr>
							<tr>
								<td>Type of Leave<font size='1'>&nbsp;&nbsp;</font></td>
								<td>
									<select name='typeOfLeave' id='typeOfLeave' onChange='undertimeIsSelected()'>
										<option name='null' value='null'>[Select Type]</option>
										<option name='SICK_LEAVE' value='SICK_LEAVE'  >Sick Leave</option>
										<option name='VACATION_LEAVE' value='VACATION_LEAVE'  >Vacation Leave</option>
										<option name='AWOL' value='AWOL'  >Absence Without Leave</option>
										<option name='COMPENSATORY' value='COMPENSATORY'  >Compensatory</option>
										<option name='FORCED' value='FORCED'  >Forced Leave</option>
										<option name='MONET_SL' value='MONET_SL'  >Monetization(SL)</option>
										<option name='MONET_VL' value='MONET_VL'  >Monetization(VL)</option>
										<option name='PARENTAL' value='PARENTAL'  >Parental Leave</option>
										<option name='REHABILITATION' value='REHABILITATION'  >Rehabilitation</option>
										<option name='RE-ENERGIZING' value='RE-ENERGIZING'  >Re-energizing</option>
										<option name='SPECIAL' value='SPECIAL'  >Special Leave</option>
										<option name='SUSPENSION' value='SUSPENSION'  >Suspension</option>
										<option name='TARDINESS' value='TARDINESS'>Tardiness</option>
										<option name='UNDERTIME' value='UNDERTIME'>Undertime</option>";
					<?php					
							if ($gender == "Female") echo "<option name='MATERNAL' value='MATERNAL'>Maternal</option>";
							if ($gender == "Male") echo "<option name='PATERNAL' value='PATERNAL'>Paternal</option>";
					?>		
							
									</select>
								<input type='hidden' name='gender' value='".$gender."'/>
								</td>
							</tr>
							<tr>
								<td>Days<font size='1'>&nbsp;&nbsp;</font></td>
								<td>
									<input type='text' name='days' id='days' size='2' maxlength='2'/>
								</td>
							</tr>
							<tr>
								<td>Start Date <font size='1'>(mm/dd/yyyy)</font></td>
								<td>
									<input type='text' name='startDate' id='startDate'maxlength='10'/>
								</td>
							</tr>
							<tr>
								<td>End Date <font size='1'>(mm/dd/yyyy)</font></td>
								<td>
									<input type='text' name='endDate' id='endDate'maxlength='10'/>
								</td>
							</tr>
							<tr>
								<td>Status<font size='1'>&nbsp;&nbsp;</font></td>
								<td>
									<select name='status' id='status'>
										<option name='null' value='null'>[Select Type]</option>
										<option name='WITH_PAY' value='WITH_PAY'>Approved With Pay</option>
										<option name='WITHOUT_PAY' value='WITHOUT_PAY'>Approved Without Pay
										</option>
									</select>
								</td>
							</tr>
							<tr>
								<td>
									<input type='hidden' name='employeeNumber' id='employeeNumber' value=".$employeeNumber.">
								</td>
								<td>
									<input type='hidden' name='time' id='time' value=''/>
								</td>
							</tr>
						</table>
						<input type='submit' name='AddLeave'/>
					</form>
					<br/><br/>
					<p class="links"><a href='menu.php' class="more">&laquo;&laquo;&nbsp;&nbsp;Home&nbsp;&nbsp;&raquo;&raquo;</a></p>					
				</div>
			</div>
		</div>
		<!-- end content -->
		<!-- start sidebars -->
		<div id="sidebar2" class="sidebar">
		</div>
		<!-- end sidebars -->
		<div style="clear: both;">&nbsp;</div>
	</div>
	</div>
	<!-- end page -->
</div>
<div id="footer">	
</div>
</body>
</html>

		
<?php		
	}
	
	public function startAdd ($dateOfFiling, $dateReceived, $typeOfLeave, $days, $startDate, $endDate, $status, $employeeNumber, $time) {
		LeaveFormView :: requestAddLeave($dateOfFiling, $dateReceived, $typeOfLeave, $days, $startDate, $endDate, $status, $employeeNumber, $time);
	}
}

?>